﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfApp2
{
    /// <summary>
    /// MyRadioButton.xaml 的交互逻辑
    /// </summary>
    public partial class MyRadioButton : Window
    {
        public MyRadioButton()
        {
            InitializeComponent();
        }

        private void ShowResult_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder str = new StringBuilder();
            foreach (UIElement sexPanelChild in sexPanel.Children)
            {
                if (sexPanelChild is RadioButton)
                {
                    RadioButton rdb = (RadioButton)sexPanelChild;
                    if (rdb.IsChecked == true)
                    {
                        str.AppendLine("性别："+rdb.Content);
                        break;
                    }
                }
            }
            foreach (UIElement dreamPanelChild in dreamPanel.Children)
            {
                if (dreamPanelChild is RadioButton)
                {
                    RadioButton rdb = (RadioButton)dreamPanelChild;
                    if (rdb.IsChecked == true)
                    {
                        str.AppendLine("梦想：" + rdb.Content);
                        break;
                    }
                }
            }
            if (str.Length > 0)
            {
                MessageBox.Show(str.ToString());
            }
        }
    }
}
